package main

import (
	"fmt"
)

func main() {
	s := make([]int, 1)
	s[0] = 1
	fmt.Println(factorial(1, s))
}

func factorial(n int, s []int) int {
	if n == 101 {
		return sum(s)
	}
	for i := 0; i < len(s); i++ {
		s[i] *= n
	}
	for i := 0; i < len(s); i++ {
		if i+1 < len(s) {
			s[i+1] += s[i] / 1e10
			s[i] %= 1e10
		} else {
			if s[i] >= 1e10 {
				s = append(s, s[i]/1e10)
				s[i] %= 1e10
			}
		}
	}
	n++
	return factorial(n, s)
}

func sum(s []int) int {
	n := 0
	for i := 0; i < len(s); i++ {
		for s[i] > 0 {
			n += s[i] % 10
			s[i] /= 10
		}
	}
	return n
}
